package reflect;

import java.util.ArrayList;
import java.util.Objects;
import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        ArrayList list = new ArrayList();
        System.out.println(list);

        //实例化一个ArrayList
        //1.获取类对象
        Class cls = Class.forName("java.util.ArrayList");
        //2.类对象提供了实例化的操作
        Object obj = cls.newInstance();
        System.out.println(obj);

        /*
            java.util.HashMap
            java.util.Date
            reflect.Person
         */
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个类名");
        String className= scanner.nextLine();
        Class cls1 = Class.forName(className);
        Object obj1 = cls1.newInstance();
        System.out.println(obj1);

    }
}
